#include <memory>
#include "OpenGLShader.h"
#include "OpenGLUtils.h"
#include <regex>
#include <sstream>
#include "shaders/ShaderChunk.h"
using std::unique_ptr;
POCELAIN_NAMESPACE_BEGIN
OpenGLShader::OpenGLShader(EShaderType shaderType)
    :mShaderType(shaderType)
{
}
OpenGLShader::~OpenGLShader()
{
    clear();
}
void OpenGLShader::clear()
{
    if(mShaderId>0)
    {
        glDeleteShader(mShaderId);
        mShaderId = 0;
    }
}
bool OpenGLShader::isValid()const
{
    if(mShaderId>0)
    {
        return glIsShader(mShaderId) == GL_TRUE;
    }
    return false;
}

void OpenGLShader::resetByString(
    const std::string &content,
    bool isRawShader
    )
{
    if(mShaderString!=content || mIsRawShader != isRawShader)
    {
        clear();
        mIsDirty = true;
        mIsRawShader = isRawShader;
        mShaderString = content;
    }

}
POCELAIN_NAMESPACE_END
